/**
 * 添加或编辑
 */
function saveAndEdit() {
    var medium = $("#medium").val();
    if(medium === ""){
        alert("请填写媒体！")
        return;
    }

    var col = $("#col").val();
    if(col === ""){
        alert("请填写栏目！")
        return;
    }

    var reporter = $("#reporter").val();
    if(reporter === ""){
        alert("请填写记者！")
        return;
    }

    var phone = $("#phone").val();
    if(phone === ""){
        alert("请填联系方式！")
        return;
    }

    var theme = $("#theme").val();
    if(theme === ""){
        alert("请填采访主题！")
        return;
    }

    var interviewTime = $("#interviewTime").val();
    if(interviewTime === ""){
        alert("请选择采访时间！")
        return;
    }

    var address = $("#address").val();
    if(address === ""){
        alert("请填采访地点！")
        return;
    }
    var target = $("#target").val();
    if(target === ""){
        alert("请填采访对象！")
        return;
    }

    var demand = $("#demand").val();
    if(demand === ""){
        alert("请填采访需求！")
        return;
    }

    // 意见
    var opinion = $("#opinion").val();

    // 领导批示
    var leaderOpinion = $("#leaderOpinion").val();

    // 承办结果
    var result = $("#result").val();

    // id
    var id = $("#id").val();

    $.ajax({
        url: "/interview/saveAndEdit",
        type: "POST",
        data: {
            'medium': medium,
            'col': col,
            'reporter': reporter,
            'phone': phone,
            'theme': theme,
            'interviewTime': interviewTime,
            'address': address,
            'target':target,
            'demand': demand,
            'opinion': opinion,
            'leaderOpinion': leaderOpinion,
            'result': result,
            'id': id
        },
        dataType: "json",
        async: false,
        success: function (data) {
            if (data.code === '200') {
                alert("操作成功！")
                window.location.href = "/interview/list";
            } else {
                alert(data.msg)
            }
        },
        error: function (e) {
            alert("操作失败！")
            console.log(e)
        }
    })
}

function cancel() {
    window.history.back();
}

